package com.youchuang.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import org.apache.log4j.Logger;

import com.alibaba.druid.util.Base64;

public class Md5CodeUtil {
	private static Logger logger = Logger.getLogger(Md5CodeUtil.class.getSimpleName());

	public static String createMd5Code(String code) {
		MessageDigest digest = null;
		try {
			digest = MessageDigest.getInstance("MD5");
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
			logger.error(e);
			return null;
		}
		byte[] b = digest.digest(code.getBytes());
		return Base64.byteArrayToAltBase64(b);
	}

}
